package com.lanou.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lanou.entity.Charity;
import com.lanou.mapper.CharityMapper;
import com.lanou.service.CharityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName CharityServiceImpl
 * @Description TODO
 * @Author lizhenjiang
 * @Date 2025年08月13日 17:24
 * @Version 1.0
 */
@Service
public class CharityServiceImpl implements CharityService {

    @Autowired
    private CharityMapper charityMapper;


    @Override
    public Charity getCharity(Integer id) {
        return charityMapper.selectCharityById(id);
    }

    @Override
    public PageInfo<Charity> getCharitys(Charity charity, Integer pageNum, Integer pageSize) {
        if(pageNum==null&&pageSize==null){
            PageInfo<Charity> pageInfo= new PageInfo<>(charityMapper.selectCharityList(charity));
            return pageInfo;
        }
        PageHelper.startPage(pageNum, pageSize);
        List<Charity> charities=charityMapper.selectCharityList(charity);
        PageInfo<Charity> pageInfo=new PageInfo<>(charities);
        return pageInfo;
    }
}
